package com.tz.fruit.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
/**
* 用户实体类
*/
@Entity
@Table(name="FRUIT_USER")
public class User implements Serializable{
	private String userId;//用户ID

	private String username;//用户名
	private String password;//密码
	private String name;//真实姓名
	private Gender gender;//性别 -枚举
	private int age;//年龄
	private String email;//邮箱
	private String tel;//手机号
	private Date birthday;//生日

	private int status;//输错密码次数，3次锁定无法登陆
	private Date unlockDate;//解锁时间

	private int rank;//权限(默认0:普通用户)  1：管理员

	private String cardNo;//绑定银行卡号	
	
	public User() {
	}

	public User(String username, String password, String name, Gender gender, int age, String email, String tel,
			Date birthday, int status, Date unlockDate, int rank, String cardNo) {
		super();
		this.username = username;
		this.password = password;
		this.name = name;
		this.gender = gender;
		this.age = age;
		this.email = email;
		this.tel = tel;
		this.birthday = birthday;
		this.status = status;
		this.unlockDate = unlockDate;
		this.rank = rank;
		this.cardNo = cardNo;
	}
	@Id
	@GeneratedValue
	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}
	@Column(nullable=false,unique=true)
	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}
	@Column(nullable=false)
	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	@Enumerated(EnumType.STRING)
	public Gender getGender() {
		return gender;
	}

	public void setGender(Gender gender) {
		this.gender = gender;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getTel() {
		return tel;
	}

	public void setTel(String tel) {
		this.tel = tel;
	}
	@Temporal(TemporalType.DATE)
	public Date getBirthday() {
		return birthday;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}
	@Temporal(TemporalType.DATE)
	public Date getUnlockDate() {
		return unlockDate;
	}

	public void setUnlockDate(Date unlockDate) {
		this.unlockDate = unlockDate;
	}

	public int getRank() {
		return rank;
	}

	public void setRank(int rank) {
		this.rank = rank;
	}

	public String getCardNo() {
		return cardNo;
	}

	public void setCardNo(String cardNo) {
		this.cardNo = cardNo;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((userId == null) ? 0 : userId.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		User other = (User) obj;
		if (userId == null) {
			if (other.userId != null)
				return false;
		} else if (!userId.equals(other.userId))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "User [userId=" + userId + ", username=" + username + ", password=" + password + ", name=" + name
				+ ", gender=" + gender + ", age=" + age + ", email=" + email + ", tel=" + tel + ", birthday=" + birthday
				+ ", status=" + status + ", unlockDate=" + unlockDate + ", rank=" + rank + ", cardNo=" + cardNo + "]";
	}
	
}
